home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / OpenTptLinks.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-14  |  6.2 KB  |  254 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OpenTptLinks.h
  3.  
  4.     Contains:    Definitions for link modules
  5.  
  6.     Copyright:    © 1994-1996 by Apple Computer, Inc., all rights reserved.
  7.  
  8.     Change History (most recent first):
  9.  
  10.          <6>     2/13/96    mjq        Add alignment pragmas
  11.          <3>    11/20/95    mjq        Add some stuff to support sniffers on links.
  12.          <2>     8/05/95    mjq        Rename kOTATMLANDevice to kOTATMLANEDevice
  13.          <1>     7/31/95    mjq        • Started over from OpenTransport project
  14.  
  15.     To Do:
  16.  
  17. */
  18.  
  19. #ifndef __OPENTPTLINKS__
  20. #define __OPENTPTLINKS__
  21.  
  22. #ifndef __OPENTRANSPORT__
  23. #include <OpenTransport.h>
  24. #endif
  25.  
  26. #if PRAGMA_ALIGN_SUPPORTED
  27. #pragma options align=mac68k
  28. #endif
  29.  
  30. /*******************************************************************************
  31. ** Device Types for OTPortRefs
  32. ********************************************************************************/
  33.  
  34. #define kPortBaseResID    1000
  35.  
  36. enum
  37. {
  38.     kOTADEVDevice            = 1,        /* An Atalk ADEV        */
  39.     kOTMDEVDevice            = 2,        /* A TCP/IP MDEV        */
  40.     kOTLocalTalkDevice        = 3,        /* LocalTalk            */
  41.     kOTIRTalkDevice            = 4,        /* IRTalk                */
  42.     kOTTokenRingDevice        = 5,        /* Token Ring            */
  43.     kOTISDNDevice            = 6,        /* ISDN                    */
  44.     kOTATMDevice            = 7,        /* ATM                    */
  45.     kOTSMDSDevice            = 8,        /* SMDS                    */
  46.     kOTSerialDevice            = 9,        /* Serial                 */
  47.     kOTEthernetDevice        = 10,        /* Ethernet                */
  48.     kOTSLIPDevice            = 11,        /* SLIP Pseudo-device    */
  49.     kOTPPPDevice            = 12,        /* PPP Pseudo-device    */
  50.     kOTModemDevice            = 13,        /* Modem Pseudo-Device    */
  51.     kOTFastEthernetDevice    = 14,        /* 100 MB Ethernet        */
  52.     kOTFDDIDevice            = 15,        /* FDDI                    */
  53.     kOTATMLANEDevice        = 16,        /* ATM LAN emulation    */
  54.     kOTATMSNAPDevice        = 17        /* ATM SNAP emulation    */
  55. };
  56.  
  57. /*******************************************************************************
  58. ** Interface option flags
  59. ********************************************************************************/
  60.  
  61. enum
  62. {
  63.     //
  64.     // Ethernet framing options
  65.     //
  66.     kOTFramingEthernet        = 0x01,
  67.     kOTFramingEthernetIPX    = 0x02,
  68.     kOTFraming8023            = 0x04,
  69.     kOTFraming8022            = 0x08
  70. };
  71.  
  72. enum
  73. {
  74.     //
  75.     // RawMode options
  76.     //
  77.     kOTRawRcvOn                    = 0,
  78.     kOTRawRcvOff                = 1,
  79.     kOTRawRcvOnWithTimeStamp    = 2
  80. };
  81.  
  82. enum
  83. {
  84.     //
  85.     // OPT_SETPROMISCUOUS value
  86.     //
  87.     DL_PROMISC_OFF            = 0
  88. };
  89.  
  90. /*******************************************************************************
  91. ** Module definitions
  92. ********************************************************************************/
  93. //
  94. // XTI Levels
  95. //
  96. enum
  97. {
  98.     LNK_ENET    = 'ENET',
  99.     LNK_TOKN    = 'TOKN',
  100.     LNK_FDDI    = 'FDDI',
  101.     LNK_TPI        = 'LTPI'
  102. };
  103. //
  104. // Module IDs
  105. //
  106. enum
  107. {
  108.     kT8022ModuleID        = 7100,
  109.     kEnetModuleID        = 7101,
  110.     kTokenRingModuleID    = 7102,
  111.     kFDDIModuleID        = 7103
  112. };
  113. //
  114. // Module Names
  115. //
  116. #define kEnet8022Name    "enet8022x"
  117. #define kEnetName        "enet"
  118. #define kFastEnetName    "fenet"
  119. #define kTokenRingName    "tokn"
  120. #define kFDDIName        "fddi"
  121. #define kIRTalkName        "irtlk"
  122. #define kSMDSName        "smds"
  123. #define kATMName        "atm"
  124. #define kT8022Name        "tpi8022x"
  125. #define kATMLANEName    "atmlane"
  126. #define kATMSNAPName    "atmsnap"
  127. //
  128. // Address Family
  129. //
  130. enum
  131. {
  132.     AF_8022        = 8200    // Our 802.2 generic address family
  133. };
  134.  
  135. /*******************************************************************************
  136. ** Options
  137. ********************************************************************************/
  138.  
  139. enum
  140. {
  141.     OPT_ADDMCAST         = 0x1000,
  142.     OPT_DELMCAST         = 0x1001,
  143.     OPT_RCVPACKETTYPE    = 0x1002,
  144.     OPT_RCVDESTADDR        = 0x1003,
  145.     OPT_SETRAWMODE        = 0x1004,
  146.     OPT_SETPROMISCUOUS    = 0x1005
  147. };
  148.  
  149. enum OTPacketType
  150. {
  151.     kETypeStandard=0,
  152.     kETypeMulticast,
  153.     kETypeBroadcast,
  154.     kETRawPacketBit = 0x80000000,
  155.     kETTimeStampBit = 0x40000000
  156. };
  157.  
  158. /*******************************************************************************
  159. ** Link related constants
  160. ********************************************************************************/
  161.  
  162. enum
  163. {
  164.     //
  165.     // length of an ENET hardware addressaddress
  166.     //
  167.     kMulticastLength            = 6,
  168.     k48BitAddrLength            = 6,
  169.     //
  170.     // The protocol type is our DLSAP
  171.     //
  172.     k8022DLSAPLength            = 2,
  173.     //
  174.     k8022SNAPLength             = 5,
  175.     //
  176.     // length of an address field used by the ENET enpoint
  177.     //    = k48BitAddrLength + sizeof(protocol type)
  178.     //
  179.     kEnetAddressLength            = k48BitAddrLength + k8022DLSAPLength,
  180.     //
  181.     // Special DLSAPS for ENET
  182.     //
  183.     kSNAPSAP                    = 0x00AA,
  184.     kIPXSAP                        = 0x00FF,
  185.     kMax8022SAP                    = 0x00FE,
  186.     k8022GlobalSAP                = 0x00FF,
  187.     kMinDIXSAP                    = 1501,
  188.     kMaxDIXSAP                    = 0xFFFFU
  189. };
  190.  
  191.  
  192.  
  193. /*******************************************************************************
  194. ** Generic Address Structure
  195. ********************************************************************************/
  196.  
  197. struct T8022Address
  198. {
  199.         OTAddressType    fAddrFamily;
  200.         UInt8            fHWAddr[k48BitAddrLength];
  201.         UInt16            fSAP;
  202.         UInt8            fSNAP[k8022SNAPLength];
  203. };
  204.  
  205. enum
  206. {
  207.         k8022BasicAddressLength = sizeof(OTAddressType) + k48BitAddrLength +
  208.                                                 sizeof(UInt16),
  209.         k8022SNAPAddressLength = sizeof(OTAddressType) + k48BitAddrLength +
  210.                                     sizeof(UInt16) + k8022SNAPLength
  211. };
  212.  
  213. /*******************************************************************************
  214. ** Some helpful stuff for dealing with 48 bit addresses
  215. ********************************************************************************/
  216.  
  217. #define OTCompare48BitAddresses(p1, p2)                                                        \
  218.     (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) &&        \
  219.      *(const UInt16*)(((const UInt8*)(p1))+4) == *(const UInt16*)(((const UInt8*)(p2))+4) )
  220.  
  221. #define OTCopy48BitAddress(p1, p2)                                                \
  222.     (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)),            \
  223.      *(UInt16*)(((UInt8*)(p2))+4) = *(const UInt16*)(((const UInt8*)(p1))+4) )
  224.  
  225. #define OTClear48BitAddress(p1)                                                    \
  226.     (*(UInt32*)((UInt8*)(p1)) = 0,                                                \
  227.      *(UInt16*)(((UInt8*)(p1))+4) = 0 )
  228.  
  229. #define OTCompare8022SNAP(p1, p2)                                                        \
  230.     (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) &&    \
  231.      *(((const UInt8*)(p1))+4) == *(((const UInt8*)(p2))+4) )
  232.  
  233. #define OTCopy8022SNAP(p1, p2)                                                \
  234.     (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)),        \
  235.      *(((UInt8*)(p2))+4) = *(((const UInt8*)(p1))+4) )
  236.  
  237. #define OTIs48BitBroadcastAddress(p1)                    \
  238.     (*(UInt32*)((UInt8*)(p1)) == 0xffffffff &&            \
  239.      *(UInt16*)(((UInt8*)(p1))+4) == 0xffff )
  240.  
  241. #define OTSet48BitBroadcastAddress(p1)                    \
  242.     (*(UInt32*)((UInt8*)(p1)) = 0xffffffff,                \
  243.      *(UInt16*)(((UInt8*)(p1))+4) = 0xffff )
  244.  
  245. #define OTIs48BitZeroAddress(p1)                \
  246.     (*(UInt32*)((UInt8*)(p1)) == 0 &&             \
  247.      *(UInt16*)(((UInt8*)(p1))+4) == 0 )
  248.  
  249. #if PRAGMA_ALIGN_SUPPORTED
  250. #pragma options align=reset
  251. #endif
  252.  
  253. #endif
  254.